using UnityEngine;
using System.Collections;

public class NPC_Level05_01 : MonoBehaviour
{
    public bool ready;


	void begin () 
    {
        ready = true;
	}

    void Update()
    {
        if (ready)
        {
            if (transform.localPosition.x < 29)
            {
                transform.position = new Vector3(transform.localPosition.x + 0.1f, transform.localPosition.y, transform.localPosition.z);
            }
            else
            {
                if (transform.localPosition.y < 2.3f)
                {
                    transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y + 0.1f, transform.localPosition.z);
                }
                else
                {
                    Destroy(this);
                }
            }
        }
        
    }

	void OnTriggerEnter (Collider obj) 
    {
        if (obj.name == "FinalDoor")
        {
            obj.gameObject.AddComponent("DoorDestroy");
            obj.GetComponent<DoorDestroy>().amount = 1f;
            obj.GetComponent<DoorDestroy>().notDestroy = true;
        }
        if (obj.name == "Floor")
        {
            if(obj.GetComponent<FlashColor>())
            transform.parent = obj.GetComponent<RoomInfo>().Father;
            GameObject.FindGameObjectWithTag("_Manager").GetComponent<FadeDemo>().FadeOut(transform);
        }
	}
}
